# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=nginx-mod-echo
pkgver=0.62
pkgrel=5

_modname="${pkgname#nginx-mod-}"

pkgdesc='Nginx module that provides directives "echo", "sleep", "time" and more'
arch=('loong64' 'x86_64')
depends=('nginx')
makedepends=('nginx-src')
url="https://github.com/openresty/echo-nginx-module"
license=('BSD')

source=(
	https://github.com/openresty/$_modname-nginx-module/archive/v$pkgver/$_modname-$pkgver.tar.gz
)
validpgpkeys=(B0F4253373F8F6F510D42178520A9993A1C052F8) # Maxim Dounin <mdounin@mdounin.ru>
sha256sums=('86f6866baf7297d85feb42ff6d9c212d1de696f3314a53d3a41a4b533a67ab01')

prepare() {
	mkdir -p build
	cd build
	ln -sf /usr/src/nginx/auto
	ln -sf /usr/src/nginx/src
}

build() {
	cd build
	/usr/src/nginx/configure --with-compat --add-dynamic-module=../$_modname-nginx-module-$pkgver
	make modules
}

package() {
	install -Dm644 "$srcdir/"$_modname-nginx-module-$pkgver/LICENSE \
	               "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	cd build/objs
	for mod in *.so; do
		install -Dm755 $mod "$pkgdir"/usr/lib/nginx/modules/$mod
	done
}
